<template>
    <div class="container">
        <h3>检测管理</h3>
        <el-tabs v-model="activeName" type="border-card" style="margin-top:20px;" @tab-click="handleClick">
            <el-tab-pane  label="中药材" name="中药材">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName1">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <!-- <el-select v-model="searchSelect1" slot="prepend" placeholder="请选择" style="min-width:100px">
                                <el-option
                                    v-for="item in searchOptionList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                    >
                                </el-option>
                            </el-select> -->
                            <el-button slot="append" @click="handleSearch1">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
					@sort-change="handlecurrentChange"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="time" sortable label="报告日期"></el-table-column>
                  <!--  <el-table-column prop="totalNum" sortable label="生产数量">
                        <template slot-scope="scope">
                            {{scope.row.totalNum}}{{scope.row.units}}
                        </template>
                    </el-table-column> -->
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
                            <el-button
                                type="text"

                                v-show="check"
                                @click="handleFrmLoss(scope.$index, scope.row)"
                            >检测</el-button>
                            <!-- <el-button
                                type="text"
                                v-if="scope.row.isCheck == '1'"
                                v-show="check1"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button> -->
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize1" @current-change="handleCurrentChange1" :total="total1" :current-page.sync="currentPage1" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane  label="辅料" name="辅料">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName2">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch2">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
					@sort-change="handlecurrentChange"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="time" sortable label="报告日期"></el-table-column>
                 <!--   <el-table-column prop="totalNum" sortable label="生产数量">
                        <template slot-scope="scope">
                            {{scope.row.totalNum}}{{scope.row.units}}
                        </template>
                    </el-table-column> -->
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
                            <el-button
                                type="text"

                                v-show="check"
                                @click="handleFrmLoss(scope.$index, scope.row)"
                            >检测</el-button>
                            <!-- <el-button
                                type="text"
                                v-if="scope.row.isCheck == '1'"
                                v-show="check1"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button> -->
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize2" @current-change="handleCurrentChange2" :total="total2" :current-page.sync="currentPage2" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="提取饮片" name="提取饮片">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName3">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch3">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
					@sort-change="handlecurrentChange"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="scTime" sortable label="报告日期"></el-table-column>
					<el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                 <!--   <el-table-column prop="totalNum" sortable label="生产数量">
                        <template slot-scope="scope">
                            {{scope.row.totalNum}}{{scope.row.units}}
                        </template>
                    </el-table-column> -->
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
                            <el-button
                                type="text"

                                v-show="check"
                                @click="handleFrmLoss(scope.$index, scope.row)"
                            >检测</el-button>
                            <!-- <el-button
                                type="text"
                                v-if="scope.row.isCheck == '1'"
                                v-show="check1"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button> -->
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize3" @current-change="handleCurrentChange3" :total="total3" :current-page.sync="currentPage3" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
			<el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(浸膏粉)" name="配方颗粒(浸膏粉)">
			    <el-row style="margin: 10px 0 20px 0">
			        <el-col :span="7">
			            <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName6">
			                <i slot="prefix" class="el-input__icon el-icon-search"></i>
			                <el-button slot="append" @click="handleSearch6">搜索</el-button>
			            </el-input>
			        </el-col>
			    </el-row>

			    <el-table
			        :data="tableData"
			        border
			        ref="multipleTable"
					@sort-change="handlecurrentChange"
			        header-cell-class-name="table-header"
			    >
			        <el-table-column prop="breedName" sortable label="名称"></el-table-column>
			        <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
			        <el-table-column prop="time" sortable label="报告日期"></el-table-column>
					<el-table-column prop="standard" sortable label="标准类型"></el-table-column>
			      <!--  <el-table-column prop="totalNum" sortable label="生产数量">
			            <template slot-scope="scope">
			                {{scope.row.totalNum}}{{scope.row.units}}
			            </template>
			        </el-table-column> -->
			        <el-table-column prop="isCheck" sortable='custom' label="检验状态">
			            <template slot-scope="scope">
			                {{scope.row.isCheck == 0?'未检测':'已检测'}}
			            </template>
			        </el-table-column>
			        <el-table-column label="操作" width="150" align="center">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
			                    @click="handleView(scope.$index, scope.row)"
			                >查看</el-button>
			                <span v-if="scope.row.isRecall == 0">
			                <el-button
			                    type="text"

			                    v-show="check"
			                    @click="handleFrmLoss(scope.$index, scope.row)"
			                >检测</el-button>

			                </span>
			                <el-button
			                    v-if="scope.row.isRecall == 1"
			                    type="info"
			                    disabled
			                >已召回</el-button>
			            </template>
			        </el-table-column>
			    </el-table>
			    <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize1" @current-change="handleCurrentChange6" :total="total6" :current-page.sync="currentPage6" style="margin-top:20px"></el-pagination>
			</el-tab-pane>
			<el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(颗粒)" name="配方颗粒(颗粒)">
			                <el-row style="margin: 10px 0 20px 0">
			                    <el-col :span="7">
			                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName5">
			                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
			                            <el-button slot="append" @click="handleSearch5">搜索</el-button>
			                        </el-input>
			                    </el-col>
			                </el-row>

			                <el-table
			                    :data="tableData"
			                    border
			                    ref="multipleTable"
								@sort-change="handlecurrentChange"
			                    header-cell-class-name="table-header"
			                >
			                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
			                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
			                    <el-table-column prop="time" sortable label="报告日期"></el-table-column>
								<el-table-column prop="standard" sortable label="标准类型"></el-table-column>
			                   <!-- <el-table-column prop="totalNum" sortable label="生产数量">
			                        <template slot-scope="scope">
			                            {{scope.row.totalNum}}{{scope.row.units}}
			                        </template>
			                    </el-table-column> -->
			                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
			                        <template slot-scope="scope">
			                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
			                        </template>
			                    </el-table-column>
			                    <el-table-column label="操作" width="150" align="center">
			                        <template slot-scope="scope">
			                            <el-button
			                                type="text"
			                                @click="handleView(scope.$index, scope.row)"
			                            >查看</el-button>
			                            <span v-if="scope.row.isRecall == 0">
			                            <el-button
			                                type="text"

			                                v-show="check"
			                                @click="handleFrmLoss(scope.$index, scope.row)"
			                            >检测</el-button>
			                           <!-- <el-button
			                                type="text"
			                                v-if="scope.row.isCheck == '1'"
			                                v-show="check1"
			                                @click="handleEdit(scope.$index, scope.row)"
			                            >编辑</el-button> -->
			                            </span>
			                            <el-button
			                                v-if="scope.row.isRecall == 1"
			                                type="info"
			                                disabled
			                            >已召回</el-button>
			                        </template>
			                    </el-table-column>
			                </el-table>
			                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize5" @current-change="handleCurrentChange5" :total="total5" :current-page.sync="currentPage5" style="margin-top:20px"></el-pagination>
			            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒" name="配方颗粒">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchName4">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch4">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
					@sort-change="handlecurrentChange"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="time" sortable label="报告日期"></el-table-column>
					<el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                  <!--  <el-table-column prop="totalNum" sortable label="生产数量">
                        <template slot-scope="scope">
                            {{scope.row.totalNum}}{{scope.row.units}}
                        </template>
                    </el-table-column> -->
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
								<el-button
								    type="text"

								    v-show="check"
								    @click="handleFrmLoss(scope.$index, scope.row)"
								>检测</el-button>
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize4" @current-change="handleCurrentChange4" :total="total4" :current-page.sync="currentPage4" style="margin-top:20px"></el-pagination>
            </el-tab-pane>

            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片(半成品)" name="中药饮片(半成品)">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchMedicalHerbSemiFormedProducts">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchMedicinalHerbSemiFormedProducts">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    @sort-change="handleCurrentChangeMedicinalHerbSemiFormedProducts"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="scTime" sortable label="报告日期"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
                            <el-button
                                type="text"

                                v-show="check"
                                @click="handleFrmLoss(scope.$index, scope.row)"
                            >检测</el-button>
                                <!-- <el-button
                                    type="text"
                                    v-if="scope.row.isCheck == '1'"
                                    v-show="check1"
                                    @click="handleEdit(scope.$index, scope.row)"
                                >编辑</el-button> -->
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pageSizeMedicinalHerbSemiFormedProducts" @current-change="handleCurrentChangeMedicinalHerbSemiFormedProducts" :total="totalMedicinalHerbSemiFormedProducts" :current-page.sync="currentPageMedicinalHerbSemiFormedProducts" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片" name="中药饮片">
                <el-row style="margin: 10px 0 20px 0">
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" style="width:300px" v-model.trim="searchMedicinalHerb">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchMedicinalHerb">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableData"
                    border
                    ref="multipleTable"
                    @sort-change="handleCurrentChangeMedicinalHerb"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="breedName" sortable label="名称"></el-table-column>
                    <el-table-column prop="batch" sortable label="检品批次"></el-table-column>
                    <el-table-column prop="scTime" sortable label="报告日期"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                    <el-table-column prop="isCheck" sortable='custom' label="检验状态">
                        <template slot-scope="scope">
                            {{scope.row.isCheck == 0?'未检测':'已检测'}}
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handleView(scope.$index, scope.row)"
                            >查看</el-button>
                            <span v-if="scope.row.isRecall == 0">
                            <el-button
                                type="text"

                                v-show="check"
                                @click="handleFrmLoss(scope.$index, scope.row)"
                            >检测</el-button>
                                <!-- <el-button
                                    type="text"
                                    v-if="scope.row.isCheck == '1'"
                                    v-show="check1"
                                    @click="handleEdit(scope.$index, scope.row)"
                                >编辑</el-button> -->
                            </span>
                            <el-button
                                v-if="scope.row.isRecall == 1"
                                type="info"
                                disabled
                            >已召回</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pageSizeMedicinalHerb" @current-change="handleCurrentChangeMedicinalHerb" :total="totalMedicinalHerb" :current-page.sync="currentPageMedicinalHerb" style="margin-top:20px"></el-pagination>
            </el-tab-pane>


        </el-tabs>
    </div>
</template>

<script>
import {detection_findByList} from "@/request/api";
import { mapState } from 'vuex';

    export default {
        data() {
            return {
                searchMedicinalHerb:'',
                currentPageMedicinalHerb:1,
                pageSizeMedicinalHerb:10,
                totalMedicinalHerb:0,

                searchMedicalHerbSemiFormedProducts:'',
                currentPageMedicinalHerbSemiFormedProducts:1,
                pageSizeMedicinalHerbSemiFormedProducts:10,
                totalMedicinalHerbSemiFormedProducts:0,

                check:true,
                check1:true,
                searchName1: '',
                searchName2: '',
                searchName3: '',
                searchName4: '',
                searchName5: '',
				searchName6: '',
                activeName: '中药材',
                materialType: '中药材',
                tableData: [],
                total1: 0,
                currentPage1:1,
                pagesize1:10,
                total2: 0,
                currentPage2:1,
                pagesize2:10,
                total3: 0,
                currentPage3:1,
                pagesize3:10,
                total4: 0,
                currentPage4:1,
                pagesize4:10,
                total5: 0,
                currentPage5:1,
                pagesize5:10,
				total6: 0,
				currentPage6:1,
				isCheck:''
            };
        },
        computed:{
            ...mapState(['switchHeadTab'])
        },
        mounted(){
            // this.init1()
			console.log(this.$store.state.storName,'检测管理的类型')

            if(this.$store.state.storName == '中药材'){
                this.activeName = '中药材'
                this.init1()
            } else if(this.$store.state.storName == '辅料'){
                this.activeName = '辅料'
                this.init2()
            } else if(this.$store.state.storName == '提取饮片'){
                this.activeName = '提取饮片'
                this.init3()
            } else if(this.$store.state.storName == '配方颗粒'){
                this.activeName = '配方颗粒'
                this.init4()
            } else if(this.$store.state.storName == '配方颗粒(颗粒)'){
                this.activeName = '配方颗粒(颗粒)'
                this.init5()
            }else if(this.$store.state.storName == '配方颗粒(浸膏粉)'){
                this.activeName = '配方颗粒(浸膏粉)'
                this.init6()
            }else if(this.$store.state.storName == '中药饮片'){
                this.activeName = '中药饮片'
                this.getMedicalHerb()
            } else if(this.$store.state.storName == '中药饮片(半成品)'){
                this.activeName = '中药饮片(半成品)'
                this.getMedicalHerbSemiFormedProducts()
            }else{
                this.activeName = '中药材'
                this.init1()
            }

        },
        created(){
            var data = JSON.stringify(this.$store.state.jc)
            var b = '编辑检测'
            var a = '检测'
            if(data.indexOf(b) != -1){
                this.check1 = true
            }else{
                this.check1 = false
            }

            if(data.indexOf(a) != -1){
                this.check = true
            }else{

                this.check = false
            }
        },
        destroyed: function () {
            this.$store.commit("setStorName","")
        },
        methods: {
			handlecurrentChange(){
				// this.isCheck = "desc"

				if(this.isCheck == "desc" || this.isCheck == ""){
					this.isCheck = "asc"
				}else{
					this.isCheck = "desc"
				}
				if(this.activeName == '中药材'){
				    this.init1()
				} else if(this.activeName == '辅料'){

				    this.init2()
				} else if(this.activeName == '提取饮片'){

				    this.init3()
				} else if(this.activeName == '配方颗粒'){

				    this.init4()
				} else if(thisactiveName == '配方颗粒(颗粒)'){

				    this.init5()
				}else if(this.activeName == '配方颗粒(浸膏粉)'){
				    this.init6()
				}else if(this.activeName == '中药饮片(半成品)'){
                    this.getMedicalHerbSemiFormedProducts()
                }else if(this.activeName == '中药饮片'){
                    this.getMedicalHerb()
                }
			},
            // 调用接口
            getMedicalHerb(){
                detection_findByList({
                    materialType: '中药饮片',
                    searchName: this.searchMedicinalHerb,
                    page: this.currentPageMedicinalHerb,
                    isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.totalMedicinalHerb = res.data.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].standard == "1"){
                            this.tableData[i].standard = "国标"
                        }else if(this.tableData[i].standard == 2){
                            this.tableData[i].standard = "省标"
                        }else{
                            this.tableData[i].standard = ""
                        }
                    }

                })
            },
            getMedicalHerbSemiFormedProducts(){
                detection_findByList({
                    materialType: '中药饮片(半成品)',
                    searchName: this.searchMedicalHerbSemiFormedProducts,
                    page: this.currentPageMedicinalHerbSemiFormedProducts,
                    isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.totalMedicinalHerbSemiFormedProducts = res.data.total
                    for(var i=0;i<this.tableData.length;i++){
                        if(this.tableData[i].standard == "1"){
                            this.tableData[i].standard = "国标"
                        }else if(this.tableData[i].standard == 2){
                            this.tableData[i].standard = "省标"
                        }else{
                            this.tableData[i].standard = ""
                        }
                    }

                })
            },

            init1(){
                detection_findByList({
                    materialType: '中药材',
                    searchName: this.searchName1,
                    page: this.currentPage1,
					isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.total1 = res.data.total
                })
            },
            init2(){
                detection_findByList({
                    materialType: '辅料',
                    searchName: this.searchName2,
                    page: this.currentPage2,
					isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.total2 = res.data.total
                })
            },
            init3(){
                detection_findByList({
                    materialType: '提取饮片',
                    searchName: this.searchName3,
                    page: this.currentPage3,
					isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.total3 = res.data.total
					for(var i=0;i<this.tableData.length;i++){
						if(this.tableData[i].standard == "1"){
							this.tableData[i].standard = "国标"
						}else if(this.tableData[i].standard == 2){
							this.tableData[i].standard = "省标"
						}else{
							this.tableData[i].standard = ""
						}
					}

                })
            },
            init4(){
                detection_findByList({
                    type: '包装',
                    materialType: '配方颗粒',
                    searchName: this.searchName4,
                    page: this.currentPage4,
					isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.total4 = res.data.total
					for(var i=0;i<this.tableData.length;i++){
						if(this.tableData[i].standard == "1"){
							this.tableData[i].standard = "国标"
						}else if(this.tableData[i].standard == 2){
							this.tableData[i].standard = "省标"
						}else{
							this.tableData[i].standard = ""
						}
					}
                })
            },
            init5(){
                detection_findByList({
                    type: '生产',
                    materialType: '配方颗粒(颗粒)',
                    searchName: this.searchName5,
                    page: this.currentPage5,
					isCheck:this.isCheck
                }).then((res) =>{
                    this.tableData = res.data.rows
                    this.total5 = res.data.total
					for(var i=0;i<this.tableData.length;i++){
						if(this.tableData[i].standard == "1"){
							this.tableData[i].standard = "国标"
						}else if(this.tableData[i].standard == 2){
							this.tableData[i].standard = "省标"
						}else{
							this.tableData[i].standard = ""
						}
					}
                })
            },
			init6(){
			    detection_findByList({
			        // type: '生产',
			        materialType: '配方颗粒(浸膏粉)',
			        searchName: this.searchName6,
			        page: this.currentPage6,
					isCheck:this.isCheck
			    }).then((res) =>{
			        this.tableData = res.data.rows
			        this.total6 = res.data.total
					for(var i=0;i<this.tableData.length;i++){
						if(this.tableData[i].standard == "1"){
							this.tableData[i].standard = "国标"
						}else if(this.tableData[i].standard == 2){
							this.tableData[i].standard = "省标"
						}else{
							this.tableData[i].standard = ""
						}
					}
			    })
			},
            // tabs
            handleClick(tab, event) {
                console.log(tab.label);
                this.materialType = tab.label
                if (this.materialType == '中药材') {
                    this.init1()
                } else if(this.materialType == '辅料') {
                    this.init2()
                } else if(this.materialType == '提取饮片'){
                    this.init3()
                } else if(this.materialType == '配方颗粒'){
                    this.init4()
                } else if(this.materialType == '配方颗粒(颗粒)'){
                    this.init5()
                }else if(this.materialType == '配方颗粒(浸膏粉)'){
                    this.init6()
                }else if(this.materialType == '中药饮片'){
                    this.getMedicalHerb()
                }else if(this.materialType == '中药饮片(半成品)'){
                    this.getMedicalHerbSemiFormedProducts()
                }
            },
            // 检测
            handleFrmLoss(index,row){
                this.$router.push({
                    path: 'detection/addDetection',
                    query: { id: row.id, isCheck: row.isCheck, type: row.type, storname: this.activeName,standard:row.standard}
                });

            },
            //编辑
            handleEdit(index,row){
                this.$router.push({
                    path: 'detection/editDetection',
                    query: { id: row.id, isCheck: row.isCheck, type: row.type, storname: this.materialType}
                });
            },
            // 查看
            handleView(index,row){
                this.$router.push({
                    path: 'detection/viewDetection',
                    query: { id: row.id, isCheck: row.isCheck, type: row.type, storname: this.activeName,standard:row.standard}
                });
            },
            //删除
            handleDelete1(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$notify({
                        title: '操作成功',
                        message: '删除成功',
                        type: 'success'
                    });
                });
            },

            handleSearchMedicinalHerb() {
                this.currentPageMedicinalHerb = 1
                this.getMedicalHerb()
            },
            handleSearchMedicinalHerbSemiFormedProducts() {
                this.currentPageMedicinalHerbSemiFormedProducts = 1
                this.getMedicalHerbSemiFormedProducts()
            },
            handleSearch1() {
                this.currentPage1 = 1
                this.init1()
            },
            handleSearch2() {
                this.currentPage2 = 1
                this.init2()
            },
            handleSearch3() {
                this.currentPage3 = 1
                this.init3()
            },
            handleSearch4() {
                this.currentPage4 = 1
                this.init4()
            },
            handleSearch5() {
                this.currentPage5 = 1
                this.init5()
            },
			handleSearch6() {
			    this.currentPage6 = 1
			    this.init6()
			},

            handleCurrentChangeMedicinalHerb(val){
                this.currentPageMedicinalHerb = val
                this.getMedicalHerb()
            },
            handleCurrentChangeMedicinalHerbSemiFormedProducts(val){
                this.currentPageMedicinalHerbSemiFormedProducts = val
                this.getMedicalHerbSemiFormedProducts()
            },


            handleCurrentChange1(val){
                this.currentPage1 = val
                this.init1()
            },
            handleCurrentChange2(val){
                this.currentPage2 = val
                this.init2()
            },
            handleCurrentChange3(val){
                this.currentPage3 = val
                this.init3()
            },
            handleCurrentChange4(val){
                this.currentPage4 = val
                this.init4()
            },
            handleCurrentChange5(val){
                this.currentPage5 = val
                this.init5()
            },
			handleCurrentChange6(val){
			    this.currentPage6 = val
			    this.init6()
			},
        }
    }
</script>

<style scoped>
.el-pagination{
    text-align: center;
}
.el-col{
    margin-bottom: 0;
}
.el-select .el-input {
width: 130px;
}
.input-with-select .el-input-group__prepend {
background-color: #fff;
}
.el-input--small .el-input__inner{
    border-radius: 5px 0 0 5px !important;
    border-right: none;
}
</style>
